﻿using System;
using HttpApiGateway;
using HttpApiGateway.Model;
using RpcClient;
using RpcHelper.Validate;
using Wedonek.RpcStore.Gateway.Interface;
using Wedonek.RpcStore.Service.Model;

namespace Wedonek.RpcStore.Gateway.Controller
{
    /// <summary>
    /// 应用身份标识
    /// </summary>
    internal class IdentityAppController : ApiController
    {
        private readonly IIdentityAppService _Service = null;

        public IdentityAppController(IIdentityAppService task)
        {
            this._Service = task;
        }
        /// <summary>
        /// 添加身份标识
        /// </summary>
        /// <param name="add"></param>
        /// <returns></returns>
        public Guid Add(IdentitySetParam add)
        {
            return this._Service.Add(add);
        }
        /// <summary>
        /// 删除身份标识
        /// </summary>
        /// <param name="id"></param>
        public void Delete([NullValidate("rpc.identity.id.null")] Guid id)
        {
            this._Service.Delete(id);
        }
        /// <summary>
        /// 获取身份标识
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public IdentityApp Get([NullValidate("rpc.identity.id.null")] Guid id)
        {
            return this._Service.Get(id);
        }
        /// <summary>
        /// 查询身份标识
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public PagingResult<IdentityApp> Query(PagingParam<IdentityQueryParam> param)
        {
            IdentityApp[] list = this._Service.Query(param.Param, param.ToBasicPaging(), out long count);
            return new PagingResult<IdentityApp>(list, count);
        }
        /// <summary>
        /// 启用或禁用身份标识
        /// </summary>
        /// <param name="set"></param>
        public void SetIsEnable(GuidParam<bool> set)
        {
            this._Service.SetIsEnable(set.Id, set.Param);
        }
        /// <summary>
        /// 更新身份标识
        /// </summary>
        /// <param name="param"></param>
        public void Set(GuidParam<IdentitySetParam> param)
        {
            this._Service.Set(param.Id, param.Param);
        }
    }
}
